<?php

/**
 * User form.
 *
 * @package    form
 * @subpackage User
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class UserForm extends BaseUserForm
{
  public function configure()
  {
    unset($this->widgetSchema['address']);
    unset($this->widgetSchema['longitude']);
    unset($this->widgetSchema['latitude']);

    $this->widgetSchema['map'] = new swWidgetFormGMapAddress();

    $object = $this->getObject();

    $this->widgetSchema['map']->setDefaults($object->toArray());

    $this->validatorSchema['map'] = new swValidatorGMapAddress;
  }

  public function processValues($values = null)
  {
    $values['address'] = $values['map']['address'];
    $values['longitude'] = $values['map']['lng'];
    $values['latitude'] = $values['map']['lat'];

    return parent::processValues($values);
  }
}
